﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using CodeGame.Networking;
using CodeGame.Networking.Clientside;

namespace CodeGame.LuaLibary
{
    static class luaLib_net
    {
        [LuaHelp("Connects to a running server")]
        public static void connect(string nick, string host)
        {
            Singletons.Network.Connect(host, nick);
        }

        [LuaHelp("Sends Global Chat")]
        public static void say(string str)
        {
            ClientProtocolChat.SendChatMessage(str);
        }

        [LuaHelp("Sends a private message to the target player")]
        public static void sayPrivate(string player, string str)
        {
            ClientProtocolChat.SendPrivateMessage(player, str);
        }

        [LuaHelp("Tests the network connection to the server")]
        public static void ping()
        {
            ClientProtocolDev.SendTestingPacket();
        }

        [LuaHelp("Disconnects from the server")]
        public static void disconnect()
        {
            Singletons.Network.Disconnect();
        }

        [LuaHelp("Returns your secure network token, do not share this!")]
        public static string getToken()
        {
            return Singletons.Network.GetToken();
        }

        [LuaHelp("Creates A listen server")]
        public static void createListen()
        {
            DedicatedServer.CreateListenServer();
        }
    }
}
